(function() {

	//4.2推荐商品
	var user_a = require("./3.用户注册与登录").user_a;
	var bus_a = require("./3.用户注册与登录").bus_a;
	var User = require("../user/_con");
	var AchCon = require("../ach/_con");
	var BuffCon = require("../buff/_con");

	var goods = bus_a.getGoodsByName("小包包");
	var user_b = new User({
		name: "小盆友",
		email: "gaubee@126.com",
		password: "123",
	});

	// var r_buff = new BuffCon({
	// 		name:"推荐折扣",
	// 		code_id:"推荐-打折",
	// 		config:{
	// 			discount:0.8,
	// 			recInt_percent:0.1
	// 		}
	// 	});
	//商家设置推荐返利的配置
	bus_a.updateRecommendConfig([{
		max_price: 1000,
		rate: 0.5
	}]);
	// console.log(bus_a.getRecommendConfig());
	// console.log(bus_a.getRecommendConfigBuff());
	// console.log(goods.getBuffs());

	var ach_id = user_a.makeAchFromGoods({
		goods_id: goods._id,
		/*推荐者*/ recommender_id: user_b._id,
		pay_method: AchCon.METHOD.担保交易
	});

	//查看订单的BUFF使用记录
	console.log(AchCon.METHOD.担保交易, AchCon.get(ach_id))

	//支付订单
	var pa_id = user_a.callBackToPayAch(ach_id);
	//等待第三方接口触发回调
	setTimeout(function() {
		var PayAchCon = require("../pay_ach/_con");
		var pa = PayAchCon.get(pa_id);
		pa.endPayAch();
		console.log("分红信息：", user_b.getAccBus());
	}, 200);

	module.exports = {
		user_a: user_a,
		bus_a: bus_a
	};
}());